#pragma once
#include <torch/torch.h>

#include <vector>

torch::Tensor from_vector_copy(const std::vector<double>& v)
{
    int64_t n = static_cast<int64_t>(v.size());
    // 先造一个空的 Tensor，再把数据 memcpy 进去
    torch::Tensor t = torch::zeros({n}, torch::kFloat64);
    std::memcpy(t.data_ptr<double>(), v.data(), n * sizeof(double));
    return t;
}